package 反射;

public class MyReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        /**
         *获取class对象的三种方式
         * 1.Class.forname("全类名");
         * 2.类名.class;
         * 3.对象.getclass();
         *
         */
        //第一种:
        //全类名=包名+类名
        Class aClass = Class.forName("反射.studentr");

        /*//第二种:
        Class studentClass = studentr.class;

        //第三种:
        studentr s=new studentr();
        Class aClass1 = s.getClass();

        //他们是同一个字节码对象
        System.out.println(aClass1==studentClass);
        System.out.println(aClass1==aClass);*/
    }
}
class student{
    private String name;
    private int age;

    public student() {
    }

    public student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "student{name = " + name + ", age = " + age + "}";
    }
}
